'use strict';
exports.main = async (event, context) => {
    const { fileID, _id } = event
	const db = uniCloud.database();
	const todos = db.collection('post-data')
	const dbCmd = db.command
	
    try {
        await uniCloud.deleteFile({
        	fileList: [fileID]
        })
		
		await todos.doc(_id).update({
			images: dbCmd.pull({
				url: fileID
			})
		})
		
        return { success: true }
    } catch (error) {
        console.error('删除文件失败:', error)
        return { success: false, error }
    }
}